package atag.gui;
/*
 * MainFrame.java
 *
 * Created on May 25, 2007, 4:18 PM
 */

/**
 *
 * @author Sirius
 */
//import java.io.*;

import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Properties;
import java.util.Vector;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import javax.swing.text.DefaultCaret;

import networkTopo.NetworkTopo;
import InterMessages.SunspotsDeployStatus;
import Tools.Executer;
import Tools.ExecuterStandard;
import Tools.SunspotsDeploy;
import Tools.Logger.LogWrapper;
import atag.common.ATaGProgram;
import atag.common.ATaGTaskDeclaration;
import atag.runtime.ln.nodeAttributesForGUI.IntegerAttribute;
import atag.runtime.ln.nodeAttributesForGUI.NodeAttribute;
import atag.runtime.ln.nodeAttributesForGUI.SetAttribute;
import atag.runtimeForGUI.NodeLocation;

public class  MainFrame extends JFrame {

    String guiBasePath = Constants.DEFAULT_GUI_BASEPATH;
    String targetCodeBasePath = Constants.DEFAULT_TARGET_CODE_BASEPATH;
    
    /**
     * Creates new form MainFrame
     */
    // TopoGraph m_topograph;
    NetworkTopo m_networkTopo;
    SunspotsDeploy m_sunspotsDeploy;
    SunspotsDeployStatus m_sunspotsDeployStatus;
    ATaGProgram atg_program;

    String compileArg0_taskGraphXML_Path;
    String compileArg1_networkDescriptionTXT_Path;
    String compileArg2_genTemplateOnly = "templateonly";
    String compileArg2_genConfigOnly = "configonly";
    String compileArg3_optmRandom = "random";
    String compileArg4_randomSeed = "0";

    String compileArg0;
    String compileArg1;
    String compileArg2 = compileArg2_genConfigOnly;
    String compileArg3;
    String compileArg4;

    private NetworkGraph networkGraph1;
    private javax.swing.JList jList1;

    private String demoDeployPath;

    //TrackDeployStatus deployStatusTracker;

    private boolean doShowGlobalNodeID = false;
    private boolean doShowGlobalRadioRange = false;
    private boolean doShowGlobalRadioLink = false;


    private int w_selectedNodeID = -1;
    private int w_selectedNodeType = -1;

    private int w_pressedNodeID = -1;
    private int w_pressedNodeType = -1;

    private String compilerArg5;
    Properties props = new Properties();
	private JTextField jTextField1;



    public static void main(String args[]){
        MainFrame mFrame = new MainFrame(new ATaGProgram());
        mFrame.setVisible(true);
    }
    
    /**
     * Sets the ATaG Program used internally. Called in case the program 
     * changes while the toolkit is still running.
     * @param atg_program 
     */
    public void setATaGProgram(ATaGProgram atg_program){
        this.atg_program = atg_program;
    }
    
    public MainFrame(ATaGProgram atg_program, String workingDir) {

        
        this(atg_program);
        
        this.guiBasePath = workingDir;
        this.targetCodeBasePath = workingDir;
        
        //AP -- horrible hack, to fix the path fields in the UI for command line.
        initField();
                
        
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }
    
    public MainFrame(ATaGProgram atg_program) {
        this.atg_program = atg_program ;
        Executer ex = new ExecuterStandard();
        try {
            //ex.executeCommand("jar xf srijan.jar conf/", new File(System.getProperty("user.dir")), null, null);
            //ex.executeCommand("jar xf srijan.jar icons/", new File(System.getProperty("user.dir")), null, null);
            props.load(new FileInputStream(System.getProperty("user.home")+ System.getProperty("file.separator") +"conf" +  System.getProperty("file.separator") + "conf.properties"));
        }
        catch (IOException e) {

        }
        LogWrapper log = new LogWrapper(props);
        try {
            log.init();
        } catch (Exception e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        initComponents();
        initLayout();
        initField();
        initDeployInfo();
    }

    private void initLayout() {
        //this.jPanel10.setSize(500, 50);
    }

    private void initField() {
    	
    	// this is the text field in the Compiler tab
    	this.jTextField10.setEditable(false);
        this.jTextField10.setText("");
        
        
        
        this.targetCodeBasePath = this.jTextField10.getText();
        
        // this is the text box inside the Tools -> Options dialog
        this.jTextField11.setText("textfield 11: " + this.guiBasePath);
        
        this.networkGraph1.setGUIBasePath(this.guiBasePath);
        File currentDirectory = new File(this.networkGraph1.getGUIBasePath());

        jFileChooser1.setCurrentDirectory(currentDirectory);
        jFileChooser2.setCurrentDirectory(currentDirectory);
        jFileChooser3.setCurrentDirectory(currentDirectory);
        
        
        this.demoDeployPath = this.compileArg0_taskGraphXML_Path = Tools.Functions.tempDir() + props.getProperty("taskfile");
        this.setDefaultCloseOperation(HIDE_ON_CLOSE);
        
    }

    private void initDeployInfo() {
        //this.jTextField10.setText(Constants.DEFAULT_TARGET_CODE_BASEPATH);


        this.m_sunspotsDeployStatus = new SunspotsDeployStatus();
        this.m_sunspotsDeploy = new SunspotsDeploy(m_sunspotsDeployStatus, this.jTextArea1, "rt",m_networkTopo);

        //Runnable deployStatusTracker = new TrackDeployStatus(m_sunspotsDeployStatus, jTextArea1, 1);
        //new Thread(deployStatusTracker).start();

        //this.jFrame1.setVisible(true);
        //this.jPanel11.setEnabled(true);
    }

    /**
     * Called by clicking compile button, initilize the compile option window
     */
    private void iniCompileWindow() {
        this.jTextField12.setText(this.compileArg0_taskGraphXML_Path);
        this.jTextField12.setEditable(false);
        this.jTextField12.setEnabled(false);
        this.jTextField13.setText(this.compileArg1_networkDescriptionTXT_Path);
        this.jTextField13.setEditable(false);
        this.jTextField13.setEnabled(false);
        this.jTextField14.setText(this.compileArg4_randomSeed);
    }

    private void invokeCompiler(String mainCompileAction) {
        this.compileArg0 = this.compileArg0_taskGraphXML_Path;
        this.compileArg1 = this.compileArg1_networkDescriptionTXT_Path;

        this.compileArg2 = mainCompileAction;

        this.compileArg3 = (String) this.jComboBox1.getSelectedItem();
        this.compileArg4 = this.jTextField14.getText();
        this.compilerArg5 = this.targetCodeBasePath;
        String[] compilerArgs = {this.compileArg0,
                this.compileArg1, this.compileArg2,
                this.compileArg3, this.compileArg4,
                this.compilerArg5};

        //TODO Gui print args of compiler here
        

        //String[] compilerArgs = {this.compileArg0_taskGraphXML_Path, this.compileArg1_networkDescriptionTXT_Path, this.compileArg2_genTemplateOnly, this.compileArg3_optmRandom, "0"};
        //String[] compilerArgs = {"D:\\DCOSS_Materials\\TaskGraphXML\\DeployDemo_BounceBall.xml", this.compileArg1, this.compileArg2, this.compileArg3, this.compileArg4};
        atag.compiler.Main.main(compilerArgs,this.atg_program.scrubAssignments());
    }


    private void setAttributeList() {

        // m_networkTopo.
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     */
    private void initComponents() {
        networkGraph1 = new NetworkGraph(props);
        jFileChooser1 = new javax.swing.JFileChooser();
        jFileChooser2 = new javax.swing.JFileChooser();
        jFileChooser3 = new javax.swing.JFileChooser();
        aboutDialog = new javax.swing.JDialog();
        jFrame1 = new javax.swing.JFrame();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jFrame2 = new javax.swing.JFrame();
        jLabel12 = new javax.swing.JLabel();
        jTextField11 = new javax.swing.JTextField();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();

        jTextField12 = new javax.swing.JTextField();
        jTextField13 = new javax.swing.JTextField();

       

        jTabbedPane1 = new javax.swing.JTabbedPane();
        nodeInformationTab = new javax.swing.JPanel();
        nodeInformationPanel = new javax.swing.JPanel();
        jTextField2 = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jTextField9 = new javax.swing.JTextField();
        jButton9 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jLabel7 = new javax.swing.JLabel();
        jTextField7 = new javax.swing.JTextField();
        jTextField8 = new javax.swing.JTextField();
        jButton5 = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jCheckBox4 = new javax.swing.JCheckBox();
        jCheckBox5 = new javax.swing.JCheckBox();
        jCheckBox6 = new javax.swing.JCheckBox();
        jCheckBox7 = new javax.swing.JCheckBox();
        jCheckBox8 = new javax.swing.JCheckBox();
        jPanel7 = new javax.swing.JPanel();
        jCheckBox9 = new javax.swing.JCheckBox();
        jCheckBox10 = new javax.swing.JCheckBox();
        jCheckBox12 = new javax.swing.JCheckBox();
        jCheckBox13 = new javax.swing.JCheckBox();
        jCheckBox14 = new javax.swing.JCheckBox();
        jPanel8 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jButton6 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton15 = new javax.swing.JButton();
        compilerDirectoryPanel = new javax.swing.JPanel();
        jTextField10 = new javax.swing.JTextField();
        compilerDirBrowseButton = new javax.swing.JButton();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox2 = new javax.swing.JCheckBox();
        jCheckBox3 = new javax.swing.JCheckBox();
        jCheckBox11 = new javax.swing.JCheckBox();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        editMenu = new javax.swing.JMenu();
        viewMenu = new javax.swing.JMenu();
        toolsMenu = new javax.swing.JMenu();

        helpMenu = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();

        jFileChooser1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFileChooser1ActionPerformed(evt);
            }
        });

        jFileChooser2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFileChooser2ActionPerformed(evt);
            }
        });

        jFileChooser3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFileChooser3ActionPerformed(evt);
            }
        });

        
        
        createAboutDialog();
        
        
        
        
    // deployment status frame  ---------------------------------------------------------------------------------------------------------
        jFrame1.setTitle("Sunspots Deployment Status - Deploying");
        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane2.setViewportView(jTextArea1);

        org.jdesktop.layout.GroupLayout jFrame1Layout = new org.jdesktop.layout.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
                jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jFrame1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 495, Short.MAX_VALUE)
                        .addContainerGap())
        );
        jFrame1Layout.setVerticalGroup(
                jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jFrame1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 374, Short.MAX_VALUE)
                        .addContainerGap())
        );
        jLabel12.setText("GUI Base Path:");

        jButton13.setText("OK");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        jButton14.setText("Cancel");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jFrame2Layout = new org.jdesktop.layout.GroupLayout(jFrame2.getContentPane());
        jFrame2.getContentPane().setLayout(jFrame2Layout);
        jFrame2Layout.setHorizontalGroup(
                jFrame2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jFrame2Layout.createSequentialGroup()
                                .addContainerGap()
                                .add(jLabel12)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jTextField11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 403, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap())
                        .add(org.jdesktop.layout.GroupLayout.TRAILING, jFrame2Layout.createSequentialGroup()
                        .addContainerGap(304, Short.MAX_VALUE)
                        .add(jButton13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(38, 38, 38)
                        .add(jButton14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 75, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
        );
        jFrame2Layout.setVerticalGroup(
                jFrame2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jFrame2Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jFrame2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(jLabel12)
                                .add(jTextField11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(254, 254, 254)
                        .add(jFrame2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(jButton13)
                                .add(jButton14))
                        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );


        createCompileDialog();
        

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Srijan");
        
        

        


        
        jPanel1.setBorder(BorderFactory.createTitledBorder(null,
        		"Group View",
        		TitledBorder.DEFAULT_JUSTIFICATION, 
        		TitledBorder.DEFAULT_POSITION, 
        		new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(153, 153, 153))
		);
        jPanel1.setEnabled(false);
        jLabel8.setText("Hardware:");

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"};

            public int getSize() {
                return strings.length;
            }

            public Object getElementAt(int i) {
                return strings[i];
            }
        });
        jScrollPane1.setViewportView(jList1);

        jLabel7.setText("Partition:");

        jTextField7.setEditable(false);
        jTextField7.setText("HS");

        jButton5.setText("Confirm");
        jButton5.setEnabled(false);
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel1Layout.createSequentialGroup()
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jLabel8)
                                .add(jLabel7))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jPanel1Layout.createSequentialGroup()
                                        .add(jTextField7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(jTextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(jButton5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE))
                                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE))
                        .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel1Layout.createSequentialGroup()
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jLabel8)
                                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(jLabel7)
                                .add(jTextField7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jTextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jButton5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
        );

        
        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Global View", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(153, 153, 153)));
        jCheckBox4.setText("Radio Range");
        jCheckBox4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox4.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jCheckBox4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox4ActionPerformed(evt);
            }
        });
        jCheckBox4.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBox4StateChanged(evt);
            }
        });

        jCheckBox5.setText("Node ID");
        jCheckBox5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox5.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jCheckBox5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox5ActionPerformed(evt);
            }
        });
        jCheckBox5.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBox5StateChanged(evt);
            }
        });

        jCheckBox6.setText("Radio Link");
        jCheckBox6.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox6.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jCheckBox6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox6ActionPerformed(evt);
            }
        });
        jCheckBox6.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBox6StateChanged(evt);
            }
        });

        jCheckBox7.setText("Sensing Range");
        jCheckBox7.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox7.setEnabled(false);
        jCheckBox7.setMargin(new java.awt.Insets(0, 0, 0, 0));

        jCheckBox8.setText("Note");
        jCheckBox8.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox8.setEnabled(false);
        jCheckBox8.setMargin(new java.awt.Insets(0, 0, 0, 0));

        org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
                jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel6Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel6Layout.createSequentialGroup()
                                .add(jCheckBox8)
                                .addContainerGap())
                        .add(jPanel6Layout.createSequentialGroup()
                        .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jCheckBox5)
                                .add(jCheckBox6))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 13, Short.MAX_VALUE)
                        .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jCheckBox4)
                                .add(jCheckBox7))
                        .addContainerGap(47, Short.MAX_VALUE))))
        );
        jPanel6Layout.setVerticalGroup(
                jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel6Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(jCheckBox5)
                                .add(jCheckBox4))
                        .add(16, 16, 16)
                        .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(jCheckBox7)
                                .add(jCheckBox6))
                        .add(16, 16, 16)
                        .add(jCheckBox8)
                        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Selection View", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(153, 153, 153)));
        jCheckBox9.setText("Radio Range");
        jCheckBox9.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox9.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jCheckBox9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox9ActionPerformed(evt);
            }
        });
        jCheckBox9.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBox9StateChanged(evt);
            }
        });

        jCheckBox10.setText("Radio Link");
        jCheckBox10.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox10.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jCheckBox10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox10ActionPerformed(evt);
            }
        });
        jCheckBox10.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBox10StateChanged(evt);
            }
        });

        jCheckBox12.setText("Node ID");
        jCheckBox12.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox12.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jCheckBox12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox12ActionPerformed(evt);
            }
        });
        jCheckBox12.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBox12StateChanged(evt);
            }
        });

        jCheckBox13.setText("Sensing Range");
        jCheckBox13.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox13.setEnabled(false);
        jCheckBox13.setMargin(new java.awt.Insets(0, 0, 0, 0));

        jCheckBox14.setText("Note");
        jCheckBox14.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox14.setEnabled(false);
        jCheckBox14.setMargin(new java.awt.Insets(0, 0, 0, 0));

        org.jdesktop.layout.GroupLayout jPanel7Layout = new org.jdesktop.layout.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
                jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel7Layout.createSequentialGroup()
                        .add(23, 23, 23)
                        .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jCheckBox14)
                                .add(jPanel7Layout.createSequentialGroup()
                                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(jCheckBox12)
                                        .add(jCheckBox10))
                                .add(18, 18, 18)
                                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jCheckBox13)
                                .add(jCheckBox9))))
                        .addContainerGap(30, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
                jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel7Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(jCheckBox12)
                                .add(jCheckBox9))
                        .add(19, 19, 19)
                        .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(jCheckBox13)
                                .add(jCheckBox10))
                        .add(18, 18, 18)
                        .add(jCheckBox14)
                        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );


        jPanel9.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jButton8.setText("Deploy");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton7.setText("Compile");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                compileButtonActionPerformed(evt);
            }
        });

        jButton15.setText("Generate Template");
        jButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton15ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel9Layout = new org.jdesktop.layout.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
                jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel9Layout.createSequentialGroup()
                        .add(55, 55, 55)
                        .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jButton8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                                .add(org.jdesktop.layout.GroupLayout.TRAILING, jButton15, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                                .add(org.jdesktop.layout.GroupLayout.TRAILING, jButton7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE))
                        .add(46, 46, 46))
        );
        jPanel9Layout.setVerticalGroup(
                jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel9Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jButton15)
                        .add(22, 22, 22)
                        .add(jButton7)
                        .add(19, 19, 19)
                        .add(jButton8)
                        .addContainerGap(19, Short.MAX_VALUE))
        );

        
        // This is the first panel within the Compiler Tab view
        compilerDirectoryPanel.setBorder(javax.swing.BorderFactory.
        		createTitledBorder(null, "Target Code Base Path", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, 
        				new java.awt.Font("Tahoma", 0, 11), 
        				new java.awt.Color(153, 153, 153)));
        
        compilerDirBrowseButton.setText("Change Project Directory");
        compilerDirBrowseButton.addActionListener(new ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	browseButtonActionPerformed();
            }
        });


        org.jdesktop.layout.GroupLayout jPanel10Layout = new org.jdesktop.layout.GroupLayout(compilerDirectoryPanel);
        compilerDirectoryPanel.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
                jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(
                    		jPanel10Layout.createSequentialGroup()
		                        .addContainerGap()
		                        .add(
		                    		jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
		                                .add(jTextField10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 206, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
		                                .add(compilerDirBrowseButton, GroupLayout.PREFERRED_SIZE, 206, GroupLayout.PREFERRED_SIZE)
		                    		)
	                        )
        );
        jPanel10Layout.setVerticalGroup(
                jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel10Layout.createSequentialGroup()
	                        .addContainerGap()
	                        .add(jTextField10, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
	                        .addContainerGap(10, 10)
	                        .add(compilerDirBrowseButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
	                        )
        );

        org.jdesktop.layout.GroupLayout jPanel8Layout = new org.jdesktop.layout.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
                jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel8Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jPanel9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(compilerDirectoryPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap(18, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
                jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel8Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(compilerDirectoryPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(24, 24, 24)
                        .add(jPanel9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(216, Short.MAX_VALUE))
        );
        jTabbedPane1.addTab("Compiler", jPanel8);

        
        
        networkGraph1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        networkGraph1.setAutoscrolls(true);
        networkGraph1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                networkGraph1MouseDragged(evt);
            }
        });
        networkGraph1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                networkGraph1MouseClicked(evt);
            }
        });

        org.jdesktop.layout.GroupLayout networkGraph1Layout = new org.jdesktop.layout.GroupLayout(networkGraph1);
        networkGraph1.setLayout(networkGraph1Layout);
        networkGraph1Layout.setHorizontalGroup(
                networkGraph1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(0, 667, Short.MAX_VALUE)
        );
        networkGraph1Layout.setVerticalGroup(
                networkGraph1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(0, 601, Short.MAX_VALUE)
        );

        jCheckBox1.setText("Node ID");
        jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });
        jCheckBox1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBox1StateChanged(evt);
            }
        });

        jCheckBox2.setText("Radio Range");
        jCheckBox2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox2.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jCheckBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox2ActionPerformed(evt);
            }
        });
        jCheckBox2.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBox2StateChanged(evt);
            }
        });

        jCheckBox3.setText("Radio Link");
        jCheckBox3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox3.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jCheckBox3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox3ActionPerformed(evt);
            }
        });
        jCheckBox3.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBox3StateChanged(evt);
            }
        });

        jCheckBox11.setText("Sensing Range");
        jCheckBox11.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jCheckBox11.setEnabled(false);
        jCheckBox11.setMargin(new java.awt.Insets(0, 0, 0, 0));

        
        createMenuBar();
        setJMenuBar(menuBar);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(layout.createSequentialGroup()
                                        .addContainerGap()
                                        .add(networkGraph1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .add(layout.createSequentialGroup()
                                .add(72, 72, 72)
                                .add(jCheckBox1)
                                .add(31, 31, 31)
                                .add(jCheckBox2)
                                .add(36, 36, 36)
                                .add(jCheckBox3)
                                .add(32, 32, 32)
                                .add(jCheckBox11)))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 300, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
        );
        layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(org.jdesktop.layout.GroupLayout.TRAILING, jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 627, Short.MAX_VALUE)
                                .add(layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                        .add(jCheckBox1)
                                        .add(jCheckBox2)
                                        .add(jCheckBox3)
                                        .add(jCheckBox11))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 9, Short.MAX_VALUE)
                                .add(networkGraph1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addContainerGap())
        );
        
        
        createNodeInformationTab();
        jTabbedPane1.addTab("Editor", nodeInformationTab);
        
        
        pack();
    }// </editor-fold>//GEN-END:initComponents

	private JMenuBar createMenuBar() {
		createFileMenu();
        createEditMenu();
        createViewMenu();
        createToolsMenu();
        createHelpMenu();

        menuBar.add(fileMenu);
        menuBar.add(editMenu);
        menuBar.add(viewMenu);
        //jMenuBar1.add(toolsMenu);
        menuBar.add(helpMenu);
        
        return menuBar;
	}

	private JMenu createHelpMenu() {
		helpMenu.setText("Help");
        jMenuItem5.setText("About");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });

        helpMenu.add(jMenuItem5);
        
        return helpMenu;
	}

	private void createEditMenu() {
		editMenu.setText("Edit");
        editMenu.setEnabled(false);
	}

	private void createViewMenu() {
		viewMenu.setText("View");
        viewMenu.setEnabled(false);
        viewMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu3ActionPerformed(evt);
            }
        });
	}

	private JMenu createToolsMenu() {
		toolsMenu.setText("Tools");
		
	    JMenuItem options = new javax.swing.JMenuItem();
        options.setText("Options");
        options.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });

        toolsMenu.add(options);
        
        return toolsMenu;
	}

	private JDialog createAboutDialog() {
        aboutDialog.setTitle("About");
        
        JLabel jLabel10 = new javax.swing.JLabel();
        JLabel jLabel11 = new javax.swing.JLabel();
        
        jLabel10.setText("Abstract Task Graph (ATaG) Compiler GUI");
        jLabel11.setText("demo");

        org.jdesktop.layout.GroupLayout jDialog1Layout = new org.jdesktop.layout.GroupLayout(aboutDialog.getContentPane());
        aboutDialog.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jDialog1Layout.createSequentialGroup()
                                .addContainerGap(311, Short.MAX_VALUE)
                                .add(jLabel11)
                                .addContainerGap())
                        .add(jDialog1Layout.createSequentialGroup()
                        .add(53, 53, 53)
                        .add(jLabel10)
                        .addContainerGap(58, Short.MAX_VALUE))
        );
        jDialog1Layout.setVerticalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jDialog1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jLabel10)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel11)
                        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        
        return aboutDialog;
	}

    private JMenu createFileMenu() {
    	fileMenu.setText("File");
    	fileMenu.addActionListener(new java.awt.event.ActionListener() {
    		public void actionPerformed(java.awt.event.ActionEvent evt) {
    			jMenu1ActionPerformed(evt);
    		}
    	});
    	
        JMenuItem jMenuItem1 = new javax.swing.JMenuItem();
        JMenuItem jMenuItem2 = new javax.swing.JMenuItem();
        JMenuItem jMenuItem3 = new javax.swing.JMenuItem();
        JMenuItem jMenuItem4 = new javax.swing.JMenuItem();
    	

    	jMenuItem1.setText("New Network Graph");
    	jMenuItem1.setEnabled(false);
    	jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
    		public void actionPerformed(java.awt.event.ActionEvent evt) {
    			jMenuItem1ActionPerformed(evt);
    		}
    	});
    	fileMenu.add(jMenuItem1);

    	jMenuItem2.setText("Load Network Graph");
    	jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
    		public void actionPerformed(java.awt.event.ActionEvent evt) {
    			jMenuItem2ActionPerformed(evt);
    		}
    	});
    	fileMenu.add(jMenuItem2);

    	jMenuItem3.setText("Save Network Graph");
    	fileMenu.add(jMenuItem3);

    	jMenuItem4.setText("Save Network Graph As");
    	jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
    		public void actionPerformed(java.awt.event.ActionEvent evt) {
    			jMenuItem4ActionPerformed(evt);
    		}
    	});
    	fileMenu.add(jMenuItem4);
    	
    	return fileMenu;
    }

    private JPanel createNodeInformationTab() {
        JButton jButton1 = new javax.swing.JButton();
        JButton jButton2 = new javax.swing.JButton();
        
        JLabel jLabel1 = new javax.swing.JLabel();
        JLabel jLabel2 = new javax.swing.JLabel();
        JLabel jLabel3 = new javax.swing.JLabel();
        JLabel jLabel4 = new javax.swing.JLabel();
        JLabel jLabel5 = new javax.swing.JLabel();
        JLabel jLabel6 = new javax.swing.JLabel();
        JLabel jLabel9 = new javax.swing.JLabel();
        
        jTextField1 = new JTextField();
    	
    	
    	nodeInformationPanel.setBorder(
    			BorderFactory.createTitledBorder(null, 
    					"Node Information", 
    					TitledBorder.DEFAULT_JUSTIFICATION, 
    					TitledBorder.DEFAULT_POSITION, 
    					new java.awt.Font("Tahoma", java.awt.Font.BOLD, 11), 
    					new java.awt.Color(27, 27, 27))
    	);
    	jLabel1.setText("Node ID:");

    	jTextField1.setFont(new java.awt.Font("Tahoma", 1, 11));

    	jLabel3.setText("X Coordinate:");

    	jTextField2.setFont(new java.awt.Font("Tahoma", 1, 11));

    	jButton3.setText("Confirm changes");
    	jButton3.addActionListener(new java.awt.event.ActionListener() {
    		public void actionPerformed(java.awt.event.ActionEvent evt) {
    			jButton3ActionPerformed(evt);
    		}
    	});
    	jButton3.setEnabled(false);

    	jLabel4.setText("Y Coordinate:");

    	jTextField3.setFont(new java.awt.Font("Tahoma", 1, 11));

    	jLabel2.setText("Abilities:");

    	jLabel5.setText("Region Label:");

    	jLabel6.setText("Region ID:");

    	jLabel9.setText("Network Address:");

    	jButton9.setText("New Node");
    	jButton9.addActionListener(new java.awt.event.ActionListener() {
    		public void actionPerformed(java.awt.event.ActionEvent evt) {
    			jButton9ActionPerformed(evt);
    		}
    	});
    	jButton9.setEnabled(false);

    	org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(nodeInformationPanel);
    	nodeInformationPanel.setLayout(jPanel4Layout);
    	jPanel4Layout.setHorizontalGroup(
    			jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    			.add(jPanel4Layout.createSequentialGroup()
    					.addContainerGap()
    					.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    							.add(jPanel4Layout.createSequentialGroup()
    									.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    											.add(jLabel9)
    											.add(jLabel1)
    											.add(jLabel3)
    											.add(jLabel4)
    											.add(jLabel5)
    											.add(jLabel6)
    											.add(jLabel2))
    											.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
    											.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
    													.add(org.jdesktop.layout.GroupLayout.LEADING, jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
    													.add(org.jdesktop.layout.GroupLayout.LEADING, jTextField9, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
    													.add(jTextField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
    													.add(jTextField3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
    													.add(jTextField5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
    													.add(jTextField6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
    													.add(jTextField4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE))
    													.addContainerGap())
    													.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
    															.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
    																	.add(org.jdesktop.layout.GroupLayout.TRAILING, jButton3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    																	.add(org.jdesktop.layout.GroupLayout.TRAILING, jButton9, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE)
    															)
    															.add(39, 39, 39))))
    	);
    	jPanel4Layout.setVerticalGroup(
    			jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    			.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
    					.add(52, 52, 52)
    					.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    							.add(jLabel1)
    							.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
    							.add(19, 19, 19)
    							.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    									.add(jLabel9)
    									.add(jTextField9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
    									.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 20, Short.MAX_VALUE)
    									.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    											.add(jLabel3)
    											.add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
    											.add(24, 24, 24)
    											.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    													.add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    													.add(jLabel4))
    													.add(20, 20, 20)
    													.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    															.add(jTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    															.add(jLabel2))
    															.add(20, 20, 20)
    															.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    																	.add(jTextField5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    																	.add(jLabel5))
    																	.add(20, 20, 20)
    																	.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
    																			.add(jTextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    																			.add(jLabel6))
    																			.add(26, 26, 26)
    																			.add(jButton9)
    																			.add(14, 14, 14)
    																			.add(jButton3)
    																			.addContainerGap()
    			)
    	);

    	jPanel5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
    	jButton1.setText("Load Network Graph");
    	jButton1.addActionListener(new java.awt.event.ActionListener() {
    		public void actionPerformed(java.awt.event.ActionEvent evt) {
    			jButton1ActionPerformed(evt);
    		}
    	});

    	jButton2.setText("Save Network Graph");
    	jButton2.addActionListener(new java.awt.event.ActionListener() {
    		public void actionPerformed(java.awt.event.ActionEvent evt) {
    			jButton2ActionPerformed(evt);
    		}
    	});
    	jButton2.setEnabled(false);


    	org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
    	jPanel5.setLayout(jPanel5Layout);
    	jPanel5Layout.setHorizontalGroup(
    			jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    			.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
    					.add(47, 47, 47)
    					.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
    							.add(org.jdesktop.layout.GroupLayout.LEADING, jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
    							.add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE))
    							.add(42, 42, 42))
    	);
    	jPanel5Layout.setVerticalGroup(
    			jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    			.add(jPanel5Layout.createSequentialGroup()
    					.addContainerGap()
    					.add(jButton1)
    					.add(21, 21, 21)
    					.add(jButton2)
    					.addContainerGap())
    	);

    	org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(nodeInformationTab);
    	nodeInformationTab.setLayout(jPanel2Layout);
    	jPanel2Layout.setHorizontalGroup(
    			jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    			.add(jPanel2Layout.createSequentialGroup()
    					.addContainerGap()
    					.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
    							.add(org.jdesktop.layout.GroupLayout.LEADING, nodeInformationPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    							.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    							.addContainerGap(35, Short.MAX_VALUE))
    	);
    	jPanel2Layout.setVerticalGroup(
    			jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
    			.add(jPanel2Layout.createSequentialGroup()
    					.addContainerGap()
    					.add(jPanel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    					.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 8, Short.MAX_VALUE)
    					.add(nodeInformationPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    					.addContainerGap())
    	);
    	
    	return nodeInformationPanel;
    }

	private void createCompileDialog() {
		// compile dialog ---------------------------------------------------------------------------------------------------------
		    
		    jFrame3 = new javax.swing.JFrame();
		    jLabel13 = new javax.swing.JLabel();
		    jLabel14 = new javax.swing.JLabel();
		    jLabel15 = new javax.swing.JLabel();
		    jLabel16 = new javax.swing.JLabel();
		    jComboBox1 = new javax.swing.JComboBox();
		    jTextField14 = new javax.swing.JTextField();
		    jButton16 = new javax.swing.JButton();
		    jButton17 = new javax.swing.JButton();
		    jButton18 = new javax.swing.JButton();
		    
		    jLabel13.setText("TT Task GraphPath:");
		    jLabel14.setText("TT Network Description Path:");
		    jLabel15.setText("TT Optimization:");
		    jLabel16.setText("TT Random Seed:");

		    String[] optimizationFlags = new String[]{"None", "Random"};
		    jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(optimizationFlags));

		    jComboBox1.addActionListener(new java.awt.event.ActionListener() {
		        public void actionPerformed(java.awt.event.ActionEvent evt) {
		            jComboBox1ActionPerformed(evt);
		        }
		    });

		    //setting default to random, and letting users edit the randomization seed
		    jComboBox1.getModel().setSelectedItem(optimizationFlags[1]);
		    
		    jTextField14.setEditable(true);
		    jTextField14.setEnabled(true);
		    jTextField14.setText(this.compileArg4_randomSeed);


		    jTextField14.addActionListener(new java.awt.event.ActionListener() {
		        public void actionPerformed(java.awt.event.ActionEvent evt) {
		            jTextField14ActionPerformed(evt);
		        }
		    });

		    jButton16.setText("Ok");
		    jButton16.addActionListener(new java.awt.event.ActionListener() {
		        public void actionPerformed(java.awt.event.ActionEvent evt) {
		            jButton16ActionPerformed(evt);
		        }
		    });

		    jButton17.setText("Cancel");
		    jButton17.addActionListener(new java.awt.event.ActionListener() {
		        public void actionPerformed(java.awt.event.ActionEvent evt) {
		            jButton17ActionPerformed(evt);
		        }
		    });

		    jButton18.setText("Help");

		    org.jdesktop.layout.GroupLayout jFrame3Layout = new org.jdesktop.layout.GroupLayout(jFrame3.getContentPane());
		    jFrame3.getContentPane().setLayout(jFrame3Layout);
		    jFrame3Layout.setHorizontalGroup(
		            jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
		                    .add(jFrame3Layout.createSequentialGroup()
		                    .addContainerGap()
		                    .add(jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
		                            .add(jLabel13)
		                            .add(jLabel14)
		                            .add(jLabel15)
		                            .add(jLabel16))
		                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 61, Short.MAX_VALUE)
		                    .add(jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
		                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jFrame3Layout.createSequentialGroup()
		                            .add(jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
		                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
		                                            .add(jTextField13)
		                                            .add(jTextField12, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 334, Short.MAX_VALUE))
		                                    .add(jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
		                                    .add(org.jdesktop.layout.GroupLayout.LEADING, jTextField14)
		                                    .add(org.jdesktop.layout.GroupLayout.LEADING, jComboBox1, 0, 84, Short.MAX_VALUE)))
		                            .addContainerGap())
		                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jFrame3Layout.createSequentialGroup()
		                    .add(jButton16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
		                    .add(32, 32, 32)
		                    .add(jButton17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
		                    .add(27, 27, 27)
		                    .add(jButton18, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
		                    .add(18, 18, 18))))
		    );
		    jFrame3Layout.setVerticalGroup(
		            jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
		                    .add(jFrame3Layout.createSequentialGroup()
		                    .addContainerGap()
		                    .add(jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
		                            .add(jTextField12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
		                            .add(jLabel13))
		                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
		                    .add(jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
		                            .add(jLabel14)
		                            .add(jTextField13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
		                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
		                    .add(jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
		                            .add(jLabel15)
		                            .add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
		                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
		                    .add(jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
		                            .add(jLabel16)
		                            .add(jTextField14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
		                    .add(82, 82, 82)
		                    .add(jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
		                            .add(jButton18)
		                            .add(jButton17)
		                            .add(jButton16))
		                    .addContainerGap(47, Short.MAX_VALUE))
		    );
		// compile dialog END ---------------------------------------------------------------------------------------------------------           
	}

    private void jTextField14ActionPerformed(java.awt.event.ActionEvent evt) {
        this.compileArg4_randomSeed = this.jTextField14.getText();
    }

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed

        jFileChooser1.showOpenDialog(null);
// TODO add your handling code here:
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
        this.jFrame3.setVisible(false);
// TODO add your handling code here:
    }//GEN-LAST:event_jButton17ActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
        this.compileArg3 = (String) this.jComboBox1.getSelectedItem();
        if (this.compileArg3.equals("Random")) {
            this.jTextField14.setEditable(true);
            this.jTextField14.setEnabled(true);
        } else if (this.compileArg3.equals("None")) {
            this.jTextField14.setEditable(false);
            this.jTextField14.setEnabled(false);
        }
    }


    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed
        invokeCompiler(this.compileArg2_genConfigOnly);
        this.jFrame3.setVisible(false);
    }//GEN-LAST:event_jButton16ActionPerformed

    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed
    	System.out.println("Generate Template: button clicked");
        invokeCompiler(this.compileArg2_genTemplateOnly);
    }//GEN-LAST:event_jButton15ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        this.jFrame2.setVisible(false);
// TODO add your handling code here:
    }//GEN-LAST:event_jButton14ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed

        String GUI_basePath = this.jTextField11.getText();
        this.networkGraph1.setGUIBasePath(GUI_basePath);

        //set base path globally.
        File currentDirectory = new File(GUI_basePath);
        jFileChooser1.setCurrentDirectory(currentDirectory);
        jFileChooser2.setCurrentDirectory(currentDirectory);
        jFileChooser3.setCurrentDirectory(currentDirectory);

        this.jFrame2.setVisible(false);

// TODO add your handling code here:
    }//GEN-LAST:event_jButton13ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        this.jFrame2.setLocation(200, 200);
        this.jFrame2.setSize(530, 380);
        this.jFrame2.setVisible(true);
        //this.jFrame2.set
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    
    private void browseButtonActionPerformed(){
    	JFileChooser fc = new JFileChooser();
    	fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    	fc.showDialog(this, "Select Dir");
    	
    	 this.targetCodeBasePath = fc.getSelectedFile().getPath();
    	 this.jTextField10.setText(this.targetCodeBasePath);
         System.out.println(this.targetCodeBasePath);
    }

    private void networkGraph1MouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_networkGraph1MouseDragged


        if (this.networkGraph1.isFileLoaded()) {
            //System.out.println("clicked");
            w_pressedNodeID = this.networkGraph1.getPressedNodeID();
            w_pressedNodeType = this.networkGraph1.getPressedNodeType();
            //System.out.println("main window click node type " + w_selectedNodeType + " id is " + w_selectedNodeID);
//            Point mousePt = evt.getPoint();
//            //System.out.println("nodes number" + m_networkTopo.nnodes);
//            // resolve into which node was clicked; based on diameter of circle
//            int clickedX = (int)mousePt.getX();
//            int clickedY = (int)mousePt.getY();
//            for (int nid=0; nid < m_networkTopo.nnodes; nid++) {
//                
//                int nodeX =(int) (m_networkTopo.getNodes().get(nid).getMyLocation().getX()*Constants.NODE_IMAGE_DISTANCE_SCALE);//+Constants.NODE_IMAGE_WIDTH/2);//networkGraph1.m_graphicNodes.get(nid).Xcoord;
//                int nodeY =(int) (m_networkTopo.getNodes().get(nid).getMyLocation().getY()*Constants.NODE_IMAGE_DISTANCE_SCALE);//+Constants.NODE_IMAGE_HEIGHT/2); //networkGraph1.m_graphicNodes.get(nid).Ycoord;
//                //System.out.println("nodes X, Y, mouse X, Y" + nodeX + " " + nodeY +" "+ clickedX + " " +clickedY);
//                if ((Math.abs(clickedX-nodeX) <= Constants.NODE_IMAGE_WIDTH/2) && (Math.abs(clickedY-nodeY) <= Constants.NODE_IMAGE_HEIGHT/2)) {
//                    w_selectedNodeID = nid;//m_networkTopo.getNodes().get(nid).getMyId();
//                    break;
//                }
//            }

            if (w_pressedNodeID != -1 && w_pressedNodeType == Constants.NODE_TYPE_COMPLETED) {

                //System.out.println("main window show existed node info");
                // Now we have the ID of the selected node
                //System.out.println("Select Node ID " + selectedNodeID);
//                Point mousePt = evt.getPoint();
//                int clickedX = (int)mousePt.getX();
//                int clickedY = (int)mousePt.getY();
//                //int newX_tl = clickedX - Constants.NODE_IMAGE_WIDTH/2;
//                //int newY_tl = clickedY - Constants.NODE_IMAGE_HEIGHT/2;
//                double realX_ct = clickedX/Constants.NODE_IMAGE_DISTANCE_SCALE; 
//                double realY_ct = clickedY/Constants.NODE_IMAGE_DISTANCE_SCALE;
                //Vector<Integer> regionsList = new Vector<Integer>();

                //jTextField1.setText(new Integer(m_networkTopo.getNodes().get(w_selectedNodeID).getMyId()).toString());
                //jTextField9.setText(m_networkTopo.getNodes().get(w_selectedNodeID).getPhysicalAddress());
                jTextField2.setText(new Integer((int) m_networkTopo.getNodes().get(w_pressedNodeID).getMyLocation().getX()).toString());
                jTextField3.setText(new Integer((int) m_networkTopo.getNodes().get(w_pressedNodeID).getMyLocation().getY()).toString());

                return;
                //jTextField7.setText(rID.toString());
            }

            if (w_pressedNodeID != -1 && w_pressedNodeType == Constants.NODE_TYPE_PROTOTYPE) {

                jTextField2.setText(new Integer((int) this.networkGraph1.m_newNodes.get(w_pressedNodeID).getMyLocation().getX()).toString());
                jTextField3.setText(new Integer((int) this.networkGraph1.m_newNodes.get(w_pressedNodeID).getMyLocation().getY()).toString());
                return;
                //jTextField7.setText(rID.toString());
            }


        }

        // TODO add your handling code here:
    }//GEN-LAST:event_networkGraph1MouseDragged

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        if (this.networkGraph1.isFileLoaded()) { //add new node button
//            if (selectedNodeID != -1) {
//                String str_sensors = jTextField4.getText();
//                String str_actuators = jTextField5.getText();
//                String str_partition = jTextField6.getText();
//                //String str_rID = jTextField7.getText();
//                String str_attrName_sensor = "attachedSensors";
//                String str_attrName_actuator = "attachedActuator";
//                String str_regName = "HS";
//                Vector newAttr = new Vector();
//                if (str_partition!= "" && str_partition!= "none") {
//                    newAttr.add(new IntegerAttribute("HS", Integer
//                            .parseInt(str_partition)));
//                }
//                if (str_sensors!= "" && str_sensors!= "none") {
//                    newAttr.add(new SetAttribute(str_attrName_sensor, str_sensors
//                            .split(",")));
//                }
//                if (str_actuators!= "" && str_actuators!= "none") {
//                    newAttr.add(new SetAttribute(str_attrName_actuator, str_actuators
//                            .split(",")));
//                }
//                m_networkTopo.getNodes().get(selectedNodeID).resetNodeAttribute(newAttr);
//            }
//        }
//        
            String regionName = "";
            Integer rID = new Integer(0);
//            Vector<String> abilityName = new Vector<String>();
//            Vector<String> abilityValue = new Vector<String>();
//            //Vector attributes = (Vector) m_networkTopo.getNodes().get(selectedNodeID).getNodeAttributes();
//            Iterator it = attributes.iterator();
//            while (it.hasNext()) {
//                NodeAttribute atr = (NodeAttribute) it.next();
//                if (atr instanceof IntegerAttribute) {
//                    // look at the name
//                    regionName = atr.getKey();
//                    rID = (Integer) atr.getValue();
//                } else {
//                    abilityName.addElement(atr.getKey());
//                    abilityValue.addElement(atr.getValue().toString());
//                }
//            }
            //networkGraph1.setSingleSelectedNodeID(selectedNodeID);
            jTextField1.setEditable(true);
            jTextField1.setEnabled(true);
            jTextField2.setEditable(true);
            jTextField2.setEnabled(true);
            jTextField3.setEditable(true);
            jTextField3.setEnabled(true);
            jTextField4.setEditable(true);
            jTextField4.setEnabled(true);
            jTextField5.setEditable(true);
            jTextField5.setEnabled(true);
            jTextField6.setEditable(true);
            jTextField6.setEnabled(true);
            jTextField9.setEditable(true);
            jTextField9.setEnabled(true);


            jTextField1.setText("");
            jTextField9.setText("");
            jTextField2.setText(new Integer((int) Constants.NODE_IMAGE_NEW_X).toString());
            jTextField3.setText(new Integer((int) Constants.NODE_IMAGE_NEW_Y).toString());
            //Object temp_obj = m_networkTopo.getNodes().get(selectedNodeID).getAttributeByName("attachedSensors");
            //if (temp_obj!=null) {
            //System.out.println("Success!!!" +(String) m_networkTopo.getNodes().get(selectedNodeID).getAttributeByName("attachedSensors"));
            //jTextField4.setText(temp_obj.toString().substring(1, temp_obj.toString().length()-1));
            //jTextField5.setText((String) (m_networkTopo.getNodes().get(selectedNodeID).getAttributeByName("attachedActuators")));
            //jTextField5.setText(m_networkTopo.getNodes().get(selectedNodeID).getAttributeByNames("attachedActuators"));
            //} else {
            jTextField4.setText("none");

            //}
            //temp_obj = m_networkTopo.getNodes().get(selectedNodeID).getAttributeByName("attachedActuators");
            //if (temp_obj!=null) {
            //System.out.println("Success!!!" +(String) m_networkTopo.getNodes().get(selectedNodeID).getAttributeByName("attachedSensors"));
            //jTextField4.setText((String) (m_networkTopo.getNodes().get(selectedNodeID).getAttributeByName("attachedSensors")));
            //System.out.println(temp_obj.toString().);
            //jTextField5.setText(temp_obj.toString().substring(1, temp_obj.toString().length()-1));
            //jTextField5.setText(m_networkTopo.getNodes().get(selectedNodeID).getAttributeByNames("attachedActuators"));
            //} else {
            jTextField5.setText("none");
            //}
            jTextField6.setText(rID.toString());
            networkGraph1.initializeNewNode();

            // TODO add your handling code here:
            //networkGraph1.
        }
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed


        this.jFrame1.setLocation(200, 200);
        this.jFrame1.setSize(500, 600);
        this.jFrame1.setVisible(true);
        jTextArea1.setEditable(false);
        jTextArea1.append("Deploying...");
        //make it auto-scroll
        DefaultCaret caret = (DefaultCaret) jTextArea1.getCaret();
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

        String[] args;
        args = new String[]{this.targetCodeBasePath};

        //run the deploy in backround through SwingWorker thread
        SunspotsDeploy dep = new SunspotsDeploy(m_sunspotsDeployStatus, jTextArea1, args[0],m_networkTopo);
        //dep.setData(m_networkTopo);
        System.out.println("Swingworker will be executed...");
        dep.execute();
        System.out.println("Swingworker has finished it's job...");

    }//GEN-LAST:event_jButton4ActionPerformed

    private void jCheckBox12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox12ActionPerformed
        if (this.networkGraph1.isFileLoaded())
            networkGraph1.setDoShowIndividualNodeID(jCheckBox12.isSelected());
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox12ActionPerformed

    private void jCheckBox10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox10ActionPerformed
        if (this.networkGraph1.isFileLoaded())
            networkGraph1.setDoShowIndividualRadioLink(jCheckBox10.isSelected());
// TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox10ActionPerformed

    private void jCheckBox9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox9ActionPerformed
        if (this.networkGraph1.isFileLoaded())
            networkGraph1.setDoShowIndividualRadioRange(jCheckBox9.isSelected());
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox9ActionPerformed

    private void jCheckBox6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox6ActionPerformed
        if (this.networkGraph1.isFileLoaded()) {
            networkGraph1.setDoShowGlobalRadioLink(jCheckBox6.isSelected());
            jCheckBox3.setSelected(jCheckBox6.isSelected());
        }
// TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox6ActionPerformed

    private void jCheckBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox4ActionPerformed
        if (this.networkGraph1.isFileLoaded()) {
            networkGraph1.setDoShowGlobalRadioRange(jCheckBox4.isSelected());
            jCheckBox2.setSelected(jCheckBox4.isSelected());
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox4ActionPerformed

    private void jCheckBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox5ActionPerformed
        if (this.networkGraph1.isFileLoaded()) {
            networkGraph1.setDoShowGlobalNodeIDs(jCheckBox5.isSelected());
            jCheckBox1.setSelected(jCheckBox5.isSelected());
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox5ActionPerformed

    private void jCheckBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox3ActionPerformed
        if (this.networkGraph1.isFileLoaded()) {
            networkGraph1.setDoShowGlobalRadioLink(jCheckBox3.isSelected());
            jCheckBox6.setSelected(jCheckBox3.isSelected());
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox3ActionPerformed

    private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox2ActionPerformed
        if (this.networkGraph1.isFileLoaded()) {
            networkGraph1.setDoShowGlobalRadioRange(jCheckBox2.isSelected());
            jCheckBox4.setSelected(jCheckBox2.isSelected());
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox2ActionPerformed

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
        if (this.networkGraph1.isFileLoaded()) {
            networkGraph1.setDoShowGlobalNodeIDs(jCheckBox1.isSelected());
            jCheckBox5.setSelected(jCheckBox1.isSelected());
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox1ActionPerformed

    private void jCheckBox12StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox12StateChanged
        //networkGraph1.setDoShowIndividualNodeID(jCheckBox12.isSelected());
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox12StateChanged

    private void jCheckBox6StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox6StateChanged
        //networkGraph1.setDoShowGlobalRadioLink(jCheckBox6.isSelected());
// TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox6StateChanged

    private void jCheckBox4StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox4StateChanged
        //networkGraph1.setDoShowGlobalRadioRange(jCheckBox4.isSelected());
// TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox4StateChanged

    private void jCheckBox5StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox5StateChanged
        //networkGraph1.setDoShowGlobalNodeIDs(jCheckBox5.isSelected());
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox5StateChanged

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        aboutDialog.setLocation(200, 200);
        aboutDialog.setSize(350, 100);
        aboutDialog.setVisible(true);
// TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_jMenu1ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed

        jButton4ActionPerformed(evt);
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton8ActionPerformed

    private void compileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        //String temp = "D:\\Research\\data\\hvacTestTopo.txt";//this.compileArg1_nDescriptionTXT_Path
        if (this.networkGraph1.isFileLoaded()) {
            this.iniCompileWindow();
            this.jFrame3.setLocation(200, 200);
            this.jFrame3.setSize(530, 380);
            this.jFrame3.setVisible(true);
            //String[] compilerArgs = {this.compileArg0_tGraphXML_Path, this.compileArg1_nDescriptionTXT_Path, this.compileArg2_oGenTemplate, this.compileArg3, this.compileArg4};
            //atag.compiler.Main.main(compilerArgs);
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jFileChooser3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser3ActionPerformed
        String command = evt.getActionCommand();
        //System.out.println(jFileChooser1.OPEN_DIALOG);
        if (command.equals(jFileChooser3.APPROVE_SELECTION)) {
            File taskGraphFile = jFileChooser3.getSelectedFile();
            String taskGraphFilePath = taskGraphFile.getPath();
            this.demoDeployPath = taskGraphFile.getPath();
            this.compileArg0_taskGraphXML_Path = taskGraphFilePath;
            //System.out.println(this.demoDeployPath+"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            //m_networkTopo = new NetworkTopo(this, topoFilePath);
            //System.out.println("read file" + topoFilePath + "path" + topoFile.getPath());
            //m_networkTopo.readTopoFromFile();
            //networkGraph1.setData(m_networkTopo);
            //networkGraph1.setIsFileLoadedFlag(true);

            //set list
            //this.updatejList1();
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jFileChooser3ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
//        String
        jFileChooser3.setCurrentDirectory(new File(this.targetCodeBasePath));
        jFileChooser3.showOpenDialog(null);// TODO add your handling code here:
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jMenu3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu3ActionPerformed
//        jFileChooser2.showSaveDialog(null);
//        jFileChooser2.setVisible(true);

// TODO add your handling code here:
    }//GEN-LAST:event_jMenu3ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed

        //ArrayList<String> al_jList1Items = new ArrayList<String>();
        //jList1.getListData();
        //attrList node


// TODO add your handling code here:
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jCheckBox3StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox3StateChanged
        //networkGraph1.setDoShowGlobalRadioLink(jCheckBox3.isSelected());

// TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox3StateChanged

    private void jCheckBox2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox2StateChanged
        //networkGraph1.setDoShowGlobalRadioRange(jCheckBox2.isSelected());

// TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox2StateChanged

    private void jCheckBox1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox1StateChanged
        //networkGraph1.setDoShowGlobalNodeIDs(jCheckBox1.isSelected());
        //jCheckBox5.setSelected(true);
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox1StateChanged

    private void jCheckBox10StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox10StateChanged
        if (this.networkGraph1.isFileLoaded())
            networkGraph1.setDoShowIndividualRadioLink(jCheckBox10.isSelected());
// TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox10StateChanged

    private void jCheckBox9StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox9StateChanged
        //networkGraph1.setDoShowIndividualRadioRange(jCheckBox9.isSelected());
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox9StateChanged

    private void jFileChooser2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser2ActionPerformed
        String command = evt.getActionCommand();
        if (command.equals(jFileChooser2.APPROVE_SELECTION)) {
            String outputFile = jFileChooser2.getSelectedFile().getAbsolutePath();
            m_networkTopo.writeTopoToFile(outputFile);
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jFileChooser2ActionPerformed

    private void networkGraph1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_networkGraph1MouseClicked
        //networkGraph1.mouseUp()processLeftClick(evt.getPoint());
        if (this.networkGraph1.isFileLoaded()) {
            //System.out.println("clicked");
            w_selectedNodeID = this.networkGraph1.getSelectedNodeID();
            w_selectedNodeType = this.networkGraph1.getSelectedNodeType();
            //System.out.println("main window click node type " + w_selectedNodeType + " id is " + w_selectedNodeID);
//            Point mousePt = evt.getPoint();
//            //System.out.println("nodes number" + m_networkTopo.nnodes);
//            // resolve into which node was clicked; based on diameter of circle
//            int clickedX = (int)mousePt.getX();
//            int clickedY = (int)mousePt.getY();
//            for (int nid=0; nid < m_networkTopo.nnodes; nid++) {
//                
//                int nodeX =(int) (m_networkTopo.getNodes().get(nid).getMyLocation().getX()*Constants.NODE_IMAGE_DISTANCE_SCALE);//+Constants.NODE_IMAGE_WIDTH/2);//networkGraph1.m_graphicNodes.get(nid).Xcoord;
//                int nodeY =(int) (m_networkTopo.getNodes().get(nid).getMyLocation().getY()*Constants.NODE_IMAGE_DISTANCE_SCALE);//+Constants.NODE_IMAGE_HEIGHT/2); //networkGraph1.m_graphicNodes.get(nid).Ycoord;
//                //System.out.println("nodes X, Y, mouse X, Y" + nodeX + " " + nodeY +" "+ clickedX + " " +clickedY);
//                if ((Math.abs(clickedX-nodeX) <= Constants.NODE_IMAGE_WIDTH/2) && (Math.abs(clickedY-nodeY) <= Constants.NODE_IMAGE_HEIGHT/2)) {
//                    w_selectedNodeID = nid;//m_networkTopo.getNodes().get(nid).getMyId();
//                    break;
//                }
//            }

            if (w_selectedNodeID != -1 && w_selectedNodeType == Constants.NODE_TYPE_COMPLETED) {

                //System.out.println("main window show existed node info");
                // Now we have the ID of the selected node
                //System.out.println("Select Node ID " + selectedNodeID);

                //Vector<Integer> regionsList = new Vector<Integer>();
                String regionName = "";
                Integer rID = new Integer(0);
                Vector<String> abilityName = new Vector<String>();
                Vector<String> abilityValue = new Vector<String>();
                Vector attributes = (Vector) m_networkTopo.getNodes().get(w_selectedNodeID).getNodeAttributes();
                Iterator it = attributes.iterator();
                while (it.hasNext()) {
                    NodeAttribute atr = (NodeAttribute) it.next();
                    if (atr instanceof IntegerAttribute) {
                        // look at the name
                        regionName = atr.getKey();
                        rID = (Integer) atr.getValue();
                    } else {
                        //TODO Why is abilityName not used?
                        //abilityName.addElement(atr.getKey());
                        //abilityValue.addElement(atr.getValue().toString());
                    }
                }
                //networkGraph1.setSingleSelectedNodeID(selectedNodeID);
                jTextField1.setText(new Integer(m_networkTopo.getNodes().get(w_selectedNodeID).getMyId()).toString());
                jTextField9.setText(m_networkTopo.getNodes().get(w_selectedNodeID).getPhysicalAddress());
                jTextField2.setText(new Integer((int) m_networkTopo.getNodes().get(w_selectedNodeID).getMyLocation().getX()).toString());
                jTextField3.setText(new Integer((int) m_networkTopo.getNodes().get(w_selectedNodeID).getMyLocation().getY()).toString());
                Object temp_obj = m_networkTopo.getNodes().get(w_selectedNodeID).getAttributeByName(ATaGTaskDeclaration.ABILITY_ATTRIBUTE_NAME);
                if (temp_obj != null) {
                    //System.out.println("Success!!!" +(String) m_networkTopo.getNodes().get(selectedNodeID).getAttributeByName("attachedSensors"));
                    //using this weird substring to remove the enclosing "[]"
                    jTextField4.setText(temp_obj.toString().substring(1, temp_obj.toString().length() - 1));
                    //jTextField5.setText((String) (m_networkTopo.getNodes().get(selectedNodeID).getAttributeByName("attachedActuators")));
                    //jTextField5.setText(m_networkTopo.getNodes().get(selectedNodeID).getAttributeByNames("attachedActuators"));
                } else {
                    jTextField4.setText("none");
                }
                
                jTextField5.setText(regionName);
                
                jTextField6.setText(rID.toString());
                return;
                //jTextField7.setText(rID.toString());
            }

            if (w_selectedNodeID != -1 && w_selectedNodeType == Constants.NODE_TYPE_PROTOTYPE) {

                // Now we have the ID of the selected node
                //System.out.println("Select Node ID " + selectedNodeID);

                //Vector<Integer> regionsList = new Vector<Integer>();
                String regionName = "";
                Integer rID = new Integer(0);
                // not used Vector<String> abilityName = new Vector<String>();
                //not used Vector<String> abilityValue = new Vector<String>();
                Vector attributes = (Vector) this.networkGraph1.m_newNodes.get(w_selectedNodeID).getNodeAttributes();
                Iterator it = attributes.iterator();
                while (it.hasNext()) {
                    NodeAttribute atr = (NodeAttribute) it.next();
                    if (atr instanceof IntegerAttribute) {
                        // look at the name
                        regionName = atr.getKey();
                        rID = (Integer) atr.getValue();
                    } else {
                        //abilityName.addElement(atr.getKey());
                        //abilityValue.addElement(atr.getValue().toString());
                    }
                }
                //networkGraph1.setSingleSelectedNodeID(selectedNodeID);
                jTextField1.setText(new Integer(this.networkGraph1.m_newNodes.get(w_selectedNodeID).getMyId()).toString());
                jTextField9.setText(this.networkGraph1.m_newNodes.get(w_selectedNodeID).getPhysicalAddress());
                jTextField2.setText(new Integer((int) this.networkGraph1.m_newNodes.get(w_selectedNodeID).getMyLocation().getX()).toString());
                jTextField3.setText(new Integer((int) this.networkGraph1.m_newNodes.get(w_selectedNodeID).getMyLocation().getY()).toString());
                Object temp_obj = m_networkTopo.getNodes().get(w_selectedNodeID).getAttributeByName(ATaGTaskDeclaration.ABILITY_ATTRIBUTE_NAME);
                if (temp_obj != null) {
                    //System.out.println("Success!!!" +(String) m_networkTopo.getNodes().get(selectedNodeID).getAttributeByName("attachedSensors"));
                    //using this weird substring to remove the enclosing "[]"
                    jTextField4.setText(temp_obj.toString().substring(1, temp_obj.toString().length() - 1));
                    //jTextField5.setText((String) (m_networkTopo.getNodes().get(selectedNodeID).getAttributeByName("attachedActuators")));
                    //jTextField5.setText(m_networkTopo.getNodes().get(selectedNodeID).getAttributeByNames("attachedActuators"));
                } else {
                    jTextField4.setText("none");
                }
                
                jTextField5.setText(regionName);
                
                jTextField6.setText(rID.toString());
            }


        }
    }//GEN-LAST:event_networkGraph1MouseClicked

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        jFileChooser2.showSaveDialog(null);
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        jFileChooser1.showOpenDialog(null);// TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser1ActionPerformed
        String command = evt.getActionCommand();
        //System.out.println(jFileChooser1.OPEN_DIALOG);
        if (command.equals(jFileChooser1.APPROVE_SELECTION)) {
            File topoFile = jFileChooser1.getSelectedFile();
            String topoFilePath = topoFile.getPath();
            this.compileArg1_networkDescriptionTXT_Path = topoFilePath;
            m_networkTopo = new NetworkTopo(this, topoFilePath);
            //m_sunspotsDeploy = new SunspotsDeploy();
            //System.out.println("read file" + topoFilePath + "path" + topoFile.getPath());
            m_networkTopo.readTopoFromFile();
            networkGraph1.setData(m_networkTopo);
            networkGraph1.setIsFileLoadedFlag(true);
            m_sunspotsDeploy.setData(m_networkTopo);

            //set list
            this.updatejList1();


            //jList1.setSelectedIndex(2);
            //m_networkTopo.nodeAttributeCollection
            //  this.updatejList1();

        }

        // TODO add your handling code here:
    }//GEN-LAST:event_jFileChooser1ActionPerformed

    private void updatejList1() {
        ArrayList<String> al_jList1Items = new ArrayList<String>();
        for (int i = 0; i < m_networkTopo.HardwareList.size(); i++) {
            for (int j = 0; j < m_networkTopo.HardwareList.get(i).valueField.size(); j++) {
                String temp_str = m_networkTopo.HardwareList.get(i).attrName + ":" + m_networkTopo.HardwareList.get(i).valueField.get(j);
                //System.out.println("here is the jlist"+temp_str);
                al_jList1Items.add(temp_str);
            }
        }
        jList1.setListData(al_jList1Items.toArray());
    }

    /*  private void updatejList1() {
            ArrayList<String> al_jList1Items = new ArrayList<String>();
            String[] ar_jList1Items;
            for (int i = 0; i < m_networkTopo.nodeAttributeCollection.size(); i++) {
                for (int j = 0; j < m_networkTopo.nodeAttributeCollection.get(i).valueField.size(); j++) {
                    al_jList1Items.add(m_networkTopo.nodeAttributeCollection.get(i).attrName + ":" + m_networkTopo.nodeAttributeCollection.get(i).valueField.get(j));
   
            jList1.setListData(aa); }
            }
   
    }*/
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        jFileChooser2.showSaveDialog(null);
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        jFileChooser1.setCurrentDirectory(new File(this.targetCodeBasePath));
        jFileChooser1.showOpenDialog(null);
        //networkGraph1.setData(m_networkTopo);
        //networkGraph1.setIsFileLoadedFlag(true);
        //networkGraph1.add(new NodeGraph());
        //networkGraph1.repaint();;
        //TODO add your handling code here:
        //networkGraph1.setVisible();
        //pack();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        if (this.networkGraph1.isFileLoaded()) {
            if (w_selectedNodeID != -1 && w_selectedNodeType == Constants.NODE_TYPE_COMPLETED) {
                String str_nodeID = jTextField1.getText();
                String str_macAddr = jTextField9.getText();
                String str_xCoord = jTextField2.getText();
                String str_yCoord = jTextField3.getText();
                String str_sensors = jTextField4.getText();
                String str_actuators = jTextField5.getText();
                String str_partition = jTextField6.getText();
                //String str_rID = jTextField7.getText();
                String str_attrName_sensor = "attachedSensors";
                String str_attrName_actuator = "attachedActuator";
                String str_regName = "HS";
                Vector newAttr = new Vector();
                if (str_partition != "" && str_partition != "none") {
                    newAttr.add(new IntegerAttribute("HS", Integer
                            .parseInt(str_partition)));
                }
                if (str_sensors != "" && str_sensors != "none") {
                    newAttr.add(new SetAttribute(str_attrName_sensor, str_sensors
                            .split(",")));
                }
                if (str_actuators != "" && str_actuators != "none") {
                    newAttr.add(new SetAttribute(str_attrName_actuator, str_actuators
                            .split(",")));
                }
                int newId = Integer.parseInt(str_nodeID);
                String newPhysicalAddress = str_macAddr;
                NodeLocation newLocation = new NodeLocation(Float.parseFloat(str_xCoord), Float.parseFloat(str_yCoord));
                m_networkTopo.getNodes().get(w_selectedNodeID).setNodeInfo(newId, newPhysicalAddress, newLocation, newAttr);//resetNodeAttribute(newAttr);
            }

            if (w_selectedNodeID != -1 && w_selectedNodeType == Constants.NODE_TYPE_PROTOTYPE) {
                String str_nodeID = jTextField1.getText();
                String str_macAddr = jTextField9.getText();
                String str_xCoord = jTextField2.getText();
                String str_yCoord = jTextField3.getText();
                String str_sensors = jTextField4.getText();
                String str_actuators = jTextField5.getText();
                String str_partition = jTextField6.getText();
                //String str_rID = jTextField7.getText();
                String str_attrName_sensor = "attachedSensors";
                String str_attrName_actuator = "attachedActuator";
                String str_regName = "none";
                //TODO this function needs to be rewritten
                Vector newAttr = new Vector();
                if (str_partition != "" && str_partition != "none") {
                    newAttr.add(new IntegerAttribute("HS", Integer
                            .parseInt(str_partition)));
                }
                if (str_sensors != "" && str_sensors != "none") {
                    newAttr.add(new SetAttribute(str_attrName_sensor, str_sensors
                            .split(",")));
                }
                if (str_actuators != "" && str_actuators != "none") {
                    newAttr.add(new SetAttribute(str_attrName_actuator, str_actuators
                            .split(",")));
                }
                int newId = Integer.parseInt(str_nodeID);
                String newPhysicalAddress = str_macAddr;
                NodeLocation newLocation = new NodeLocation(Float.parseFloat(str_xCoord), Float.parseFloat(str_yCoord));
                if (this.m_networkTopo.isNodeIdExist(newId) == false) {
                    m_networkTopo.addNewNodeToNetwork(newId, newPhysicalAddress, newLocation, newAttr);//resetNodeAttribute(newAttr);

                } else {
                    return;
                }
            }
        }
        networkGraph1.setConfirmNodeChanges(this.w_selectedNodeType);
    }//GEN-LAST:event_jButton3ActionPerformed

    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) throws Exception {
//
//        SwingUtilities.invokeLater(new Runnable() {
//            public void run() {
//                new MainFrame().setVisible(true);
//            }
//        });
//    }

    private JButton jButtonx;
    //TopoGraph m_topograph;
    // Variables declaration - do not modify//GEN-BEGIN:variables

	private JButton compilerDirBrowseButton;
    private JButton jButton13;
    private JButton jButton14;
    private JButton jButton15;
    private JButton jButton16;
    private JButton jButton17;
    private JButton jButton18;
    private JButton jButton3;
    private JButton jButton5;
    private JButton jButton6;
    private JButton jButton7;
    private JButton jButton8;
    private JButton jButton9;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox10;
    private javax.swing.JCheckBox jCheckBox11;
    private javax.swing.JCheckBox jCheckBox12;
    private javax.swing.JCheckBox jCheckBox13;
    private javax.swing.JCheckBox jCheckBox14;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JCheckBox jCheckBox3;
    private javax.swing.JCheckBox jCheckBox4;
    private javax.swing.JCheckBox jCheckBox5;
    private javax.swing.JCheckBox jCheckBox6;
    private javax.swing.JCheckBox jCheckBox7;
    private javax.swing.JCheckBox jCheckBox8;
    private javax.swing.JCheckBox jCheckBox9;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JDialog aboutDialog;
    private javax.swing.JFileChooser jFileChooser1;
    private javax.swing.JFileChooser jFileChooser2;
    private javax.swing.JFileChooser jFileChooser3;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JFrame jFrame2;
    private javax.swing.JFrame jFrame3;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenu viewMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JMenu toolsMenu;
    private javax.swing.JMenuBar menuBar;

    private javax.swing.JMenuItem jMenuItem5;

    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel compilerDirectoryPanel;
    private javax.swing.JPanel nodeInformationTab;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel nodeInformationPanel;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField11;
    
    //TODO Gui delete jtextfield12
    private javax.swing.JTextField jTextField12;
    
    
    private javax.swing.JTextField jTextField13;
    private javax.swing.JTextField jTextField14;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField jTextField9;

    // End of variables declaration//GEN-END:variables

}
